﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SafeScript.MetaModel.Statements
{
    public class BindTermOperator : Operator
    {
        public PropertyOperator Operator;

        public override ITypeDef ComputeType(ITypeDef goal, bool needsRef, ErrorReport report)
        {
            ITypeDef typedef = this.Operator.ComputeType(goal, needsRef, report);

            // Check that the operator really points to a property
            if (!(this.Operator.Object is Property))
            {
                report.Add(new ErrorEntry(this.Node) { Type = ErrorType.BindingNeedsPropertyOrFunction });
                return null;
            }

            return typedef;
        }
    }
}
